import 'package:flutter/material.dart';
import 'package:flutter_09_game/config/app_color.dart';
import 'package:flutter_09_game/generated/locales.g.dart';
import 'package:flutter_09_game/utils/loading/loading_animation.dart';
import 'package:flutter_09_game/widgets/empty/empty_no_data.dart';
import 'package:get/get.dart';

import '../../../generated/assets.dart';
import '../empty/empty_view.dart';

mixin BaseLoadingMixin on Widget {
  Widget buildLoading() {
    return Center(
      child: Padding(
        padding: const EdgeInsets.only(bottom: 50),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            // const AutoImage(Assets.hudLoading, width: 40),

            const LoadingAnimation(color: AppColor.primary),
            const SizedBox(height: 8),
            Text(LocaleKeys.loading.tr,
                style: TextStyle(
                    fontSize: 12, color: Colors.white.withOpacity(0.6))),
          ],
        ),
      ),
    );
  }

  Widget buildNoNetwork() {
    return GestureDetector(
      onTap: clickToRefresh,
      child: EmptyNoData.notDataView(
          // image: image,
          // message: message,
          ),
    );
  }

  Widget buildError({String? message}) {
    return GestureDetector(
      onTap: clickToRefresh,
      child: EmptyNoData.notDataView(
        // image: image,
        message: message,
      ),
    );
  }

  Widget buildEmpty({String? message}) {
    return EmptyNoData.notDataView(
      message: message,
    );
  }

  void clickToRefresh() {}

  Widget buildDefaultLoadingWidget() {
    return Container(
      alignment: Alignment.center,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          SizedBox(
              width: 20,
              height: 20,
              child: CircularProgressIndicator(
                  strokeWidth: 2, color: Colors.white.withOpacity(0.6))),
          SizedBox(width: 12),
          Text(LocaleKeys.loading.tr,
              style: TextStyle(
                  fontSize: 12, color: Colors.white.withOpacity(0.6))),
        ],
      ),
    );
  }
}
